package com.cloudcentral.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloudcentral.exception.FailureException;
import com.cloudcentral.entity.DisabledFrequency;
import com.cloudcentral.mapper.DisabledFrequencyMapper;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 禁用频率表 服务实现类
 * </p>
 *
 * @author Administrator
 * @since 2023-11-23
 */
@Slf4j
@Service
public class DisabledFrequencyService extends ServiceImpl<DisabledFrequencyMapper, DisabledFrequency> {

  @Transactional(rollbackFor = {Exception.class})
  @GlobalTransactional(rollbackFor = {Exception.class})
  public Boolean submit(DisabledFrequency disabledFrequency) throws FailureException {
    if (StringUtils.isBlank(disabledFrequency.getValues())) throw new FailureException("缺少禁用频率");
    else return saveOrUpdate(disabledFrequency);
  }

  @Transactional(rollbackFor = {Exception.class})
  @GlobalTransactional(rollbackFor = {Exception.class})
  public Boolean delete(Long id) {
    return removeById(id);
  }
}
